import java.io.File

// 模拟FileFormatConfig类的功能
object TestFileFormatConfig {
    private val SUPPORTED_EXTENSIONS = setOf(
        "pdf", "epub", "mobi", "txt", "azw", "azw3", "fb2", "djvu", "cbr", "cbz"
    )
    
    fun isSupportedFile(fileName: String): Boolean {
        val extension = fileName.substringAfterLast('.', "").lowercase()
        val isSupported = extension in SUPPORTED_EXTENSIONS
        println("检查文件: $fileName, 扩展名: $extension, 是否支持: $isSupported")
        return isSupported
    }
}

// 测试函数
fun testFileScanning() {
    println("=== 测试文件格式识别 ===")
    
    val testFiles = listOf(
        "test.epub",
        "test.mobi",
        "test.pdf",
        "test.txt",
        "test.doc",
        "电路基础.epub",
        "素描基础教程——石膏几何体.epub",
        "test_book.mobi"
    )
    
    testFiles.forEach { fileName ->
        TestFileFormatConfig.isSupportedFile(fileName)
    }
    
    println("\n=== 测试实际文件扫描 ===")
    val testDir = File("d:/workspace/drl/system/EsayRead/test_file")
    if (testDir.exists()) {
        println("测试目录存在: ${testDir.absolutePath}")
        testDir.listFiles()?.forEach { file ->
            if (file.isFile) {
                val isSupported = TestFileFormatConfig.isSupportedFile(file.name)
                println("文件: ${file.name}, 大小: ${file.length()}, 支持: $isSupported")
            }
        }
    } else {
        println("测试目录不存在: ${testDir.absolutePath}")
    }
}

// 运行测试
testFileScanning()